@extends('master')

@section('content')

      <div class="row-fluid ">
        <div class="span12 box gradient ">
          <div class="title">
          <div class="row-fluid">
          <h3 style="padding-bottom:5px;">
            <div class="tools">
              <a class="btn" href="javascript:history.go(-1)" >
              <i class="fa fa-hand-o-left"></i>返回
              </a>
            </div>
            <i class="fa  fa-list-ol"></i> 物品目录管理

          </h3>
          </div>
          </div><!-- End .title -->
        <div class="content">
          <ul id="tabExample1" class="nav nav-tabs">
          @foreach($pub as $key => $type)
            <li @if($key == 0) class="active" @endif><a href="#partner{{ $key }}" data-toggle="tab">{{ $type->AppID }}</a></li>
          @endforeach
            <li><a href="#add-type" data-toggle="modal" data-target="#add-type"><i class="fa fa-plus-square"></i>新增目录</a></li>
          </ul>
          <div class="tab-content" id="staff_list">

          @foreach($pub as $key => $type)
            <div class="tab-pane fade  @if($key == 0)  in active @endif" id="partner{{ $key }}">
            @if(empty($coms[$type->id]))

              <div class="empty">
                <p class="oops">OOPS!本目录没有物品条目</p>
                <a class="btn btn-large btn-block btn-primary"  onclick="set_type_id({{ $type->id }})" data-toggle="modal" data-target="#add-catalog"><i class="fa fa-plus"></i> 创建第一个条目</a>
                <!-- 系统目录不可删除 -->
              </div>

            @else

                <table id="datatable_in" class="responsive table table-striped table-bordered" style="width:100%;margin-bottom:0; ">
                    <thead>
                        <tr>
                            <th width="60">编码</th>
                            <th>名称</th>
                            <th>规格型号</th>
                            <th width="80">单价</th>
                            <th width="80">单位</th>
                            <th width="100">包装数量</th>
                            <th width="100">包装尺寸</th>
                            <th width="100">包装重量</th>
                            <th width="100">更新日期</th>
                            <th width="80">经办人</th>
                            <th width="120">操作</th>
                       </tr>
                  </thead>
                  <tbody>
              @foreach($coms[$type->id] as $list)
              <?php $info = unserialize($list->info); ?>
              <tr>
                    <td>{{ $list->id }}</td>
                    <td>{{ $list->name }}</td>
                   <td>{{ $info['guige'] }}</td>
                   <td>{{ $list->price }}</td>
                   <td>{{ $info['danwei'] }}</td>
                   <td>{{ $info['shuliang'] }}</td>
                   <td>{{ $info['chicun'] }}</td>
                   <td>{{ $info['zhongliang'] }}</td>
                   <td>{{ substr($list->udpated_at,0,-9) }}</td>
                   <td>{{ $list->user->name }}</td>
                   <td>
                      <div class="btn-group1">
                        <a class="btn" rel="tooltip" data-placement="left" data-original-title="修改" data-toggle="modal" data-target="#edit-catalog"><i class="fa fa-edit"></i></a>
                       <a class="btn" rel="tooltip" data-placement="left" data-original-title="删除" data-toggle="modal" data-target="#confirm_alert"><i class="fa fa-trash"></i></a>
                     </div>
                   </td>
                 </tr>
              @endforeach


               </tbody>
            </table>
                <div class="row-fluid control-group">
                 <div class="pull-left span6" action="#">
                    <a data-toggle="modal" onclick="set_type_id({{ $type->id }})" data-target="#add-catalog" class="btn">
                      <i class="fa fa-plus"></i> 新增一条
                    </a>
                  </div>
                 <div class="span6">
                    <div class="pagination pull-right ">
                      <ul>
                       <li><a href="#">上一页</a></li>
                        <li><a href="#">1</a></li>
                        <li><a href="#">2</a></li>
                        <li><a href="#">3</a></li>
                        <li><a href="#">4</a></li>
                        <li><a href="#">下一页</a></li>
                      </ul>
                    </div>
                  </div>
                </div>
                <br/>
            @endif
               <!-- End row-fluid -->
            </div>
          @endforeach
          </div>
        </div> <!-- End .content -->
        </div>
        <!-- End box -->
      </div>



<div id="edit-catalog" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 class="modal-title" id="myModalLabel">编辑物品条目</h3>
      </div>
      <div class="modal-body">

            <form class="form-horizontal" action="#">
              <div class="form-row control-group row-fluid">
                <label class="control-label span3" for="default-textarea">物品名称</label>
                <div class="controls span7">
                <input type="text" id="type-name" class="row-fluid" placeholder="必填" value="RO-6主机">
                </div>
              </div>
              <div class="form-row control-group row-fluid">
                <label class="control-label span3" for="default-textarea">采购单价</label>
                <div class="controls span7 input-prepend row-fluid">
                    <span class="add-on prepend "><i class="fa fa-cny"></i></span>
                    <input class="row-fluid" id="combined-input" size="16" type="text" placeholder="必填"  value="800">
                </div>
              </div>
              <div class="form-row control-group row-fluid">
                <label class="control-label span3" for="default-textarea">基本单位</label>
                <div class="controls span7 ">
                    <input class="row-fluid" id="combined-input" size="16" type="text" placeholder="必填"  value="台">
                </div>
              </div>
              <div class="form-row control-group row-fluid">
                <label class="control-label span3" for="default-textarea">规格参数</label>
                <div class="controls span7">
                <input type="text" id="type-name" class="row-fluid">
                </div>
              </div>
              <div class="form-row control-group row-fluid">
                <label class="control-label span3" for="default-textarea">包装数量</label>
                <div class="controls span7 input-append row-fluid">
                    <input class="row-fluid prepend" id="combined-input" size="16" type="text">
                    <span class="add-on ">/件</span>
                </div>
              </div>
              <div class="form-row control-group row-fluid">
                <label class="control-label span3" for="default-textarea">包装尺寸</label>
                <div class="controls span7">
                <input type="text" id="type-name" class="row-fluid">
                </div>
              </div>
              <div class="form-row control-group row-fluid">
                <label class="control-label span3" for="default-textarea">包装重量</label>
                <div class="controls span7 input-append row-fluid">
                    <input class="row-fluid" id="combined-input" size="16" type="text">
                    <span class="add-on ">KG</span>
                </div>
              </div>
            </form>


      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button type="button" class="btn btn-primary"><i class="fa fa-save"></i> 保存</button>
      </div>
    </div>
  </div>
</div>

<div id="add-catalog" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 class="modal-title" id="myModalLabel">创建物品条目</h3>
      </div>
                {!! Form::open(['url' => route('commodities.store'), 'class' => 'form-horizontal', 'role' => 'form']) !!}
      <div class="modal-body">

                <input type="hidden" name="type_id" id="type_id" value="">
              <div class="form-row control-group row-fluid">
                <label class="control-label span3" for="default-textarea">物品名称</label>
                <div class="controls span7">
                <input type="text" id="type-name" name="name" class="row-fluid" placeholder="必填">
                </div>
              </div>
              <div class="form-row control-group row-fluid">
                <label class="control-label span3" for="default-textarea">采购单价</label>
                <div class="controls span7 input-prepend row-fluid">
                    <span class="add-on prepend "><i class="fa fa-cny"></i></span>
                    <input class="row-fluid" id="combined-input" name="price" size="16" type="text" placeholder="必填">
                </div>
              </div>
              <div class="form-row control-group row-fluid">
                <label class="control-label span3" for="default-textarea">基本单位</label>
                <div class="controls span7 ">
                    <input class="row-fluid" id="combined-input" name="danwei" size="16" type="text" placeholder="必填"  value="">
                </div>
              </div>
              <div class="form-row control-group row-fluid">
                <label class="control-label span3" for="default-textarea">规格参数</label>
                <div class="controls span7">
                <input type="text" id="type-name" name="guige" class="row-fluid">
                </div>
              </div>
              <div class="form-row control-group row-fluid">
                <label class="control-label span3" for="default-textarea">包装数量</label>
                <div class="controls span7 input-append row-fluid">
                    <input class="row-fluid prepend" name="shuliang" id="combined-input" size="16" type="text">
                    <span class="add-on ">/件</span>
                </div>
              </div>
              <div class="form-row control-group row-fluid">
                <label class="control-label span3" for="default-textarea">包装尺寸</label>
                <div class="controls span7">
                <input type="text" id="type-name" name="chicun" class="row-fluid">
                </div>
              </div>
              <div class="form-row control-group row-fluid">
                <label class="control-label span3" for="default-textarea">包装重量</label>
                <div class="controls span7 input-append row-fluid">
                    <input class="row-fluid" id="combined-input" name="zhongliang" size="16" type="text">
                    <span class="add-on ">KG</span>
                </div>
              </div>


      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button type="submit" class="btn btn-primary"><i class="fa fa-plus"></i> 提交</button>
      </div>
            {!! Form::close() !!}
    </div>
  </div>
</div>


<div id="add-type" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 class="modal-title" id="myModalLabel">创建目录</h3>
      </div>
      <div class="modal-body">

            <form class="form-horizontal" action="#">
              <div class="form-row control-group row-fluid">
                <label class="control-label span3" for="default-textarea">目录名称</label>
                <div class="controls span7">
                <input type="text" id="type-name" class="row-fluid">
                <br/>&nbsp
                </div>
              </div>
            </form>


      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button type="button" class="btn btn-primary"><i class="fa fa-plus"></i> 提交</button>
      </div>
    </div>
  </div>
</div>


<div id="confirm_alert" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 class="modal-title" id="myModalLabel">确定本次操作吗？</h3>
      </div>
      <div class="modal-body">
        <i class=" fa fa-warning red pull-left fs_24"></i>

        <p>一旦【确定】，本次操作不可撤销。</p>

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button type="button" class="btn btn-primary"><i class="fa fa-trash"></i> 确定删除</button>
      </div>
    </div>
  </div>
</div>

@stop


@section('script')
<script type='text/javascript'>
    $(window).load(function() {
     $('#loading').fadeOut();
    });
      $(document).ready(function() {
      $('body').css('display', 'none');
      $('body').fadeIn(500);


      $("#logo a, #sidebar_menu a:not(.accordion-toggle), a.ajx").click(function() {
      event.preventDefault();
      newLocation = this.href;
      $('body').fadeOut(500, newpage);
      });
      function newpage() {
      window.location = newLocation;
      }

    });
    </script>
    <script>
    function set_type_id(type_id){
        $('#type_id').val(type_id)
    }
    </script>
@stop